package com.bookrecomm.entity;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.Builder;

import java.math.BigDecimal;

import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 市场趋势实体类
 * 记录不同时间段、不同分类下的市场销售趋势数据
 */
@Data
@Entity
@Table(name = "market_trend")
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class MarketTrend {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    /**
     * 分类ID
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "category_id")
    private Category category;
    
    /**
     * 日期
     */
    @Column(nullable = false)
    private LocalDate date;
    
    /**
     * 销量
     */
    @Column(nullable = false)
    private Integer sales;
    
    /**
     * 平均评分
     */
    @Column(name = "avg_rating", precision = 3, scale = 1)
    private BigDecimal avgRating;
    
    /**
     * 收藏数
     */
    @Column(name = "favorite_count", nullable = false)
    private Integer favoriteCount;
    
    /**
     * 创建时间
     */
    @Column(name = "created_at", nullable = false)
    private LocalDateTime createdAt;
    
    /**
     * 更新时间
     */
    @Column(name = "updated_at", nullable = false)
    private LocalDateTime updatedAt;
}
